package com.some;

import java.util.HashMap;

public class XiaPi_2_2 {
    public int MinOperations(String s) {
        char[] chars = s.toCharArray();
        int start = 0, end = s.length() - 1;
        HashMap<Character, Integer> map = new HashMap<>();
        for (char aChar : chars) {
            map.put(aChar, map.getOrDefault(aChar, 0) + 1);
        }
        int charA = map.get('A');
        int charB = map.get('B');
        char startChar = 'A';
        if ((end + 1) % 2 == 1) {
            if (charA < charB) {
                startChar = 'B';
            }
        }
        int res = 0;
        while (start <= end) {
            if (start % 2 == 0 && chars[start] != startChar) {
                res++;
            }
            if (start % 2 == 1 && chars[start] == startChar) {
                start++;
            }

            end--;
        }
        return 0;
    }
}
